package com.hkbigdata.transfrom;

import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

/**
 * @author liuanbo
 * @creat 2023-04-19-17:18
 * @see 2194550857@qq.com
 */
public class Flink02_TransFrom_FlatMap_Anonymous {
    public static void main(String[] args) throws Exception {
        //1.创建环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

/*        env.fromElements(1,2,3,4)
                .flatMap(new FlatMapFunction<Integer, Integer>() {
                    @Override
                    public void flatMap(Integer value, Collector<Integer> out) throws Exception {
                        out.collect(value*value*value);
                    }
                }).print();*/


        env.fromElements(1,2,3,4)
                .flatMap((Integer value ,Collector<Integer> out)->{
                    out.collect(value*value);
                    out.collect(value*value*value);
                }).returns(Types.INT).print();

        env.execute();
    }
}
